package logic;

import entities.MovableEntity;

/** The class that updates the movable entity's coordinates.
 * @author Team 1
 *
 */
public class MovementThread extends Thread {
	
	MovableEntity entity;	//The entity to be processed.
	
	/** The MoveentThread's constructor.
	 * @param entity : The movable to be processed. 
	 */
	public MovementThread(MovableEntity entity) {
		super();
		this.entity = entity;
	}
	
	public void run() {
		while(!Thread.currentThread().isInterrupted() && entity.canMove()) {
			//Updates the entity's coordinates.
			entity.update();
			try {
				Thread.sleep(20);
			} catch (InterruptedException e) {
				Thread.currentThread().interrupt();
			}
		}
		this.interrupt();
	}
}
